package com.bdk.middle.management.web;

import com.bdk.middle.common.result.web.ObjectResponse;
import com.bdk.middle.management.api.domain.AdminDO;
import com.bdk.middle.management.api.domain.RoleDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: xxx
 * @Date: 2021/3/3 0003 11:37
 * @Description:
 */

@RestController
public class IndexController {

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @RequestMapping(value="/index.html", method = RequestMethod.GET)
    public @ResponseBody
    ObjectResponse index() {
        ObjectResponse response = new ObjectResponse();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        HttpEntity<String> formEntity = new HttpEntity<String>("{}", headers);
        ResponseEntity<String> result = restTemplate().postForEntity("http://127.0.0.1:8889/app/tenant/list.html", formEntity, String.class);
        System.out.println(result.getBody());
        return response;
    }
}
